﻿using System;
using System.Collections.Generic;
using System.Data.SQLite;
using InformationSystem.Dao;
using InformationSystem.Entity;

namespace InformationSystem.Service
{
	/// <summary>
	/// Description of Programme.
	/// </summary>
	public class ProgrammeService:IService<Programme>
	{
		ProgrammeDao pDao = new ProgrammeDao();
		
		public ProgrammeService()
		{
		}

		#region IService implementation

		public bool add(Programme objct)
		{
			return pDao.add(objct);
		}

		public bool del(Programme objct)
		{
			return pDao.del(objct);
		}

		public bool update(Programme objct)
		{
			return pDao.update(objct);
		}

		public Programme query(Programme objct)
		{
			return pDao.query(objct);
		}

		public List<Programme> queryAll()
		{
			return pDao.queryAll();
		}

		#endregion
		
		public SQLiteDataAdapter getDisplayColumn()
		{
            String sql = "select id, name , CASE status WHEN 1 THEN 'create' WHEN 2 THEN 'in use' WHEN 3 THEN 'retiring' end as status, level, year from t_programme order by id asc;";
			
			return pDao.getDisplayColumn(sql);
		}
		
		
		public bool addOrUpdate(Programme objct)
		{
			if(objct.id > 0)
			{
				return update(objct);
			}
			
			return add(objct);
		}
		
	}
	
}
